package dexter.util;

import java.util.Hashtable;
import java.util.Timer;
import java.util.Vector;

public class ResourceManager {

	private static Hashtable<String, Vector<Timer>> timers = new 
				   Hashtable<String, Vector<Timer>>();
	
	public static synchronized Timer createTimer(String session) {
		Timer t = new Timer();
		
		Vector<Timer> ts = timers.get(session);
		if (ts==null) ts = new Vector<Timer>();
		ts.add(t);
		timers.put(session,ts);
		
		return t;
	}
	
	public static synchronized void stopTimers(String session) {
		
		Vector<Timer> ts = timers.remove(session);
		if (ts!=null) {
			for (Timer t: ts) {
				t.cancel();
			}
		}
		
	}

}
